/*
A Changer
control_C
title_C
trigger_C
score_C
cap_active_C
zone_C



*/


while {true} do {
sleep dure_cap;

//////////////////// ACTIF //////////////////////////////////////////////////////////////
if ((control_B == 1) && (control_D == -1))  then { // Zone B ATT et Zone D DEF
cap_active_C = true;
_type = getMarkerType "title_C"; if (_type != "selector_selectedMission") then {"title_C" setMarkerType "selector_selectedMission"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// BLOQUER //////////////////////////////////////////////////////////
if ((control_B == 0) or (control_D == 0)) then { // Zone B ou D neutre
cap_active_C = false;
_type = getMarkerType "title_C"; if (_type != "selector_selectable") then {"title_C" setMarkerType "selector_selectable"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// VERROUILLER ///////////////////////////////////////////////////////
if ((control_B == -1) && (control_C == -1))  then { // B et C DEF => verrouiller par DEF
cap_active_C = false;
score_C = -100;
_color = getMarkerColor "zone_C"; if (_color != "ColorRed") then {"zone_C" setMarkerColor "colorRed"};
_color = getMarkerColor "title_C"; if (_color != "ColorRed") then {"title_C" setMarkerColor "colorRed"};
_type = getMarkerType "title_C"; if (_type != "mil_box") then {"title_C" setMarkerType "mil_box"};
};

if ((control_C == 1) && (control_D == 1))  then { // C et D ATT => verrouiller par ATT
cap_active_C = false;
score_C = 100;
_color = getMarkerColor "zone_C"; if (_color != "ColorBlue") then {"zone_C" setMarkerColor "colorBlue"};
_color = getMarkerColor "title_C"; if (_color != "ColorBlue") then {"title_C" setMarkerColor "colorBlue"};
_type = getMarkerType "title_C"; if (_type != "mil_box") then {"title_C" setMarkerType "mil_box"};
};
////////////////////////////////////////////////////////////////////////////////////////





//////////////////// Script Cap /////////////////////////////////////////////////////////////
if (cap_active_C) then {

	// Qui controle ?
	
	// Zone Neutre
	if (control_C == 0) then {
		if (score_C == 100) then {control_C = 1; "title_C" setMarkerColor "ColorBlue"}; // zone cap par Att
		if (score_C == -100) then {control_C = -1; "title_C" setMarkerColor "ColorRed"}; // zone cap par Def
	};
	
	// Zone capé
	if ((control_C == 1) && (score_C <= 0)) then {control_C = 0; "title_C" setMarkerColor "ColorBlack"}; // zone perdu par ATT, devient neutre
	if ((control_C == -1) && (score_C >= 0)) then {control_C = 0; "title_C" setMarkerColor "ColorBlack"}; // zone perdu par DEF, devient neutre
	

	
	// CAP
	
	// Att > Def
	if (score_C < 100) then {
		if ((att_side countside list trigger_C) > (def_side countside list trigger_C)) then {
			_nb_att = ((att_side countside list trigger_C) - (def_side countside list trigger_C));
			score_C = score_C + _nb_att;
			if (score_C > 100) then {score_C = 100}; // on ne dépasse pas 100
		};
	};
	
	// Def > Att
	if (score_C > -100) then {
		if ((def_side countside list trigger_C) > (att_side countside list trigger_C)) then {
			_nb_def = ((def_side countside list trigger_C) - (att_side countside list trigger_C));
			score_C = score_C - _nb_def;
			if (score_C < -100) then {score_C = -100}; // on ne dépasse pas -100
		};
	};
	
	
	
	// Couleur markeur 
	if (score_C < 0) then {  // zone cap par DEF
		_alpha = score_C / -200;  
		"zone_C" setMarkerAlpha _alpha; 
		"zone_C" setMarkerColor "ColorRed"
	};
			
	if (score_C > 0) then {  // zone cap par ATT
		_alpha = score_C / 200;  
		"zone_C" setMarkerAlpha _alpha; 
		"zone_C" setMarkerColor "ColorBlue"
	};
	
	if (score_C == 0) then {  // Neutre invisible.
	"zone_C" setMarkerAlpha 0;
	"title_C" setMarkerColor "ColorBlack";
	};

	
}; 


};